<script
	src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/grocery.js"
	type="text/javascript">
</script>
	
<script src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/jquery.js" type="text/javascript"></script>
<script src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/flash.js" type="text/javascript"></script>
  
  
   <script src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/calendar.js" type="text/javascript"></script>
   <script src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/calendar-setup.js" type="text/javascript"></script>
   <script src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?>/calendar-en.js" type="text/javascript"></script>
   
   
   <link rel="stylesheet" type="text/css" href="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_css');?>/skins/aqua/theme.css" />
    

<script type="text/javascript">

function enablecsv()
{
	document.getElementById("browsecsv").style.display = "";
}
addgrocery_url="<?=base_url();?>index.php/admin/services/addGrocery";
editgrocery_url="<?=base_url();?>index.php/admin/services/editGrocery";
deletegrocery_url="<?=base_url();?>index.php/admin/services/deleteGrocery";
loading_img_url="<?=base_url();?>public/images/ajax-loader.gif";
loading_img_url_edit="<?=base_url();?>public/images/ajax-loader_edit.gif";
</script>

<?if(isAdmin()){?>
<h2><?=$action?> <div style="float: right"><span class="addbutton">
<?=anchor('services/samplecsv','Download Sample csv file') ?>
<!--<a  href="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('CNC_csv').'/'.$this->config->item('CNC_sample_csv');?>" >Download Sample csv file</a>-->
<a  href="javascript:void(0);" onclick="enablecsv();">Upload CSV File</a>
</span></div></h2><?}
else {?> <h1><?=$action?></h1><?}?>
<div style="display: none;margin-top: 5px" id="browsecsv">

  <?=form_open_multipart($this->uri->uri_string()) ?>
  	   	  
  	 <input type="file" name="file" id="file" />
  	 <input type="hidden" name = 'userid' value='<? if(isset($id)) echo $id;?>'/>
  	
  	   <input type="submit" value="upload" /> 

  	 </form>
  	 
  </div>
  <?php 
  ?>
<!--  form for adding grocery -->
<table>
<tr>

          <td colspan="6" id="cont"></td>
        </tr>

	<tr>
	
		<td><?=form_input(array('id'=>'itemname',
                      'name'=>'itemname',
                     'value' =>'Enter Item Name',
		             'class' => 'grocery',
		              'onblur'=>'onblur_grocery(this.id,\'Enter Item Name\')',      
                     'size'  => '15',
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Name\')')); ?></td>
		<td> <?=form_input(array('id'=>'itembrand',
                              'name'=>'itembrand',
		             'class' => 'grocery',
		    'onblur'=>'onblur_grocery(this.id,\'Enter Item Brand\')',              
            		             'size'  => '15',
                      'value' =>'Enter Item Brand', 
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Brand\')')); ?></td>
		<td> <?=form_input(array('id'=>'itemquantity',
                     'name'=>'itemquantity',
                     'value' =>'Enter Item Quantity',
		    'onblur'=>'onblur_grocery(this.id,\'Enter Item Quantity\')',                      
              
		             'class' => 'grocery',             
                     'size'  => '15',
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Quantity\')')); ?></td>
		
                <td>
                
                <?=form_input(array('id'=>'itemdate',
                     'name'=>'itemdate',
                     'value' =>'EnterDate &Time',
                     'class' => 'grocery',
		             'size'  => '15',
		            'onblur'=>'onblur_grocery(this.id,\'Enter Item Date\')',            
                   'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Date\')')); ?>
                
                <button style="height: 20px" type="reset" id="f_trigger_b"><img src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_images');?>/calender.gif" style="border:0px;" /></button>
               </td> 
          <script type="text/javascript">
    Calendar.setup({
        inputField     :    "itemdate",      // id of the input field
        ifFormat       :    "%Y-%m-%d %H:%M:%S %p",       // format of the input field
        showsTime      :    true,            // will display a time selector
        button         :    "f_trigger_b",   // trigger for the calendar (button ID)
        singleClick    :    false,           // double-click mode
        timeFormat     :    "24",
        step           :    1                // show all years in drop-down boxes (instead of every other year as default)
    });
</script>
          
          
         <!--  <script type="text/javascript">//<![CDATA[

      var cal = Calendar.setup({
          onSelect: function(cal) { cal.hide() }
      });
      cal.manageFields("f_btn1", "itemdate", "%Y-%m-%d");
      //]]>
    </script>-->

                
		<td><? $attributes="id='schedule' class='grocery'"; ?>
             <?=form_dropdown('delivery_type',$options,'',$attributes)?></td>
		
	
	   <td><?=form_submit(array('class'=>'submit',
					 'name'=>'Add', 
					 'id'=>'submit',
		             'size'  => '15',
		             'class' => 'grocery',
	                 'value'=> 'Add ',
		             'onmouseover'=> 'show_grocery_image()',
		             'onmouseout' => 'hide_grocery_image()',
                     'onclick'=>"validate_grocery('$id','itemname','itembrand','itemquantity','itemdate','schedule')"))?>
      
      </td>
      <td>
         <img id="grocery_image" style="visibility:hidden;" src="<?=base_url().$this->config->item('FAL_assets_admin').'/'.$this->config->item('FAL_images')?>/grocery.jpg" alt="add grocery" title="add grocery">
      </td>
	</tr>
	
	<tr id="edit_tr" style="visibility:hidden">
	<input type="hidden" id="editid" />
	<input type="hidden" id="userid" value="<?=$id?>" />
		<td><?=form_input(array('id'=>'editname',
                      'name'=>'itemname',
                     'value' =>'Enter Item Name', 
		             'size'  => '15',
		             'class' => 'grocery',
		     'onblur'=>'onblur_grocery(this.id,\'Enter Item Name\')',
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Name\')')); ?></td>
		<td>  <?=form_input(array('id'=>'editbrand',
                              'name'=>'itembrand',
                     'value' =>'Enter Item Brand',
		            'size'  => '15',
		             'class' => 'grocery',
		     'onblur'=>'onblur_grocery(this.id,\'Enter Item Brande\')',              
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Brand\')')); ?></td>
		<td> <?=form_input(array('id'=>'editquantity',
                     'name'=>'itemquantity',
                     'value' =>'Enter Item Quantity', 
		             'size'  => '15',
		             'class' => 'grocery',
		     'onblur'=>'onblur_grocery(this.id,\'Enter Item Quantity\')',                      
             'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Quantity\')')); ?></td>
		<td><?=form_input(array('id'=>'editdate',
                     'name'=>'itemdate',
                     'value' =>'Enter Item Date',
		             'size'  => '15',
		             'class' => 'grocery', 
		          'onblur'=>'onblur_grocery(this.id,\'Enter Item Date\')',            
                'onfocus' => 'onfocus_grocery(this.id,\'Enter Item Date\')')); ?>
                 <button style="height: 20px" type="reset" id="f_trigger_b1"><img src="<?=base_url().$this->config->item('FAL_assets_shared').'/'.$this->config->item('FAL_images');?>/calender.gif" style="border:0px;" /></button>
                 <script type="text/javascript">
    Calendar.setup({
        inputField     :    "editdate",      // id of the input field
        ifFormat       :    "%Y-%m-%d %H:%M:%S %p",       // format of the input field
        showsTime      :    true,            // will display a time selector
        button         :    "f_trigger_b1",   // trigger for the calendar (button ID)
        singleClick    :    false,           // double-click mode
        timeFormat     :    "24",
        step           :    1                // show all years in drop-down boxes (instead of every other year as default)
    });
</script>
                </td>
		<td><? $attributes="id='editschedule'"; ?>
             <?=form_dropdown('delivery_type',$options,'',$attributes)?></td>
             
          <td><?=form_submit(array('class'=>'submit',
					 'name'=>'Add', 
					 'id'=>'submit',
		             'class' => 'grocery',
		             'size'  => '5',
	                 'value'=> 'Edit',
                     'onclick'=>"validate_grocery('edit','editname','editbrand','editquantity','editdate','editschedule',".$id.")"))?>

       </td>   
	</tr>
</table>
<!-- form for adding grocery -->
<div style="float:right;" id="ajax_loader"></div>
<p>&nbsp;</p>
<div id="table_grocery" />
<? if(isset($grocery)){?>
<table cellpadding="5px">
<tbody id="table">
	<tr>
		<th scope="col">Item Name</th>
		<th scope="col">Item Brand</th>
		<th scope="col">Quantity</th>
		<th scope="col">Date</th>
		<th scope="col">Schedule</th>
		<th scope="col">Manage</th>

	</tr>


  <?php 
  if(isset($grocery))
  foreach($grocery as $item):?>
   
  <tr class="center" id="<?=$item->id ?>">
  <td style="display:none">
  <input type="hidden" id="gid<?=$item->id?>" value="<?=$item->id?>" /></td>
		<td id="name<?=$item->id?>"><?=$item->name;?></td>
		<td id="brand<?=$item->id?>"><?=$item->brand;?></td>
		<td id="quantity<?=$item->id?>"><?=$item->quantity;?></td>
		<td id="date<?=$item->id?>"><?=$item->date;?></td>
		<td id="schedule<?=$item->id?>"><?=$item->schedule;?></td>
		<td>
        <?php
           echo '<img src="'.base_url().$this->config->item('FAL_assets_admin').'/'.$this->config->item('FAL_images').'/pencil.png" alt="edit" title="edit" onclick="javascript:edit(\''.$item->id.'\')" >';
           echo '<img src="'.base_url().$this->config->item('FAL_assets_admin').'/'.$this->config->item('FAL_images').'/cross.png" alt="delete" title="delete" onclick="javascript:delete_grocery(\''.$item->id.'\')" >';
        ?>
    </td>

	</tr>
  <?php endforeach;?>

</tbody>
</table>
<?} else{
  echo "<center>You Don't Have any Grocery Items Added Till Now...</center>";
  }?>
</div>

